<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/1
 * Time: 14:13
 */

namespace vendor;

use vendor\user\user;
use vendor\user\VIP1;
use vendor\user\VIP2;
use vendor\user\VIP3;

require 'user\user.php';
require 'user\VIP1.php';
require 'user\Vip2.php';
require 'user\Vip3.php';


class manager
{
    private $arr = [];

    public function OpenSite()
    {
        $this->arr[] = $this->createUser(0);
        $this->arr[] = $this->createUser(0);
        $this->arr[] = $this->createUser(0);
        $this->arr[] = $this->createUser(0);
        $this->arr[] = $this->createUser(1);
        $this->arr[] = $this->createUser(2);
        $this->arr[] = $this->createUser(3);

        echo '<br />数组个数： ' . count($this->arr) . '<br />';
    }

    public function CloseSite()
    {
        echo '<br />关闭网站<br />';
    }


    private function showOnlineNum()
    {
        echo '<br />在线人数： ' . user::getOnlineNum() . '<br />';
    }

    public function __destruct()
    {
        echo '清除manager对象';
    }

    private function createUser($level)
    {
        $user=null;
        switch ($level){
            case 0:
                $user = new user();
                break;
            case 1:
                $user = new VIP1();
                break;
            case 2:
                $user = new Vip2();
                break;
            case 3:
                $user = new Vip3();
                break;
        }
        $this->showOnlineNum();
        $user->mylevel();
        return $user;
    }


   /* private function createCommonUser()
    {
        $user = new user();
        $this->showOnlineNum();
        $user->mylevel();
        return $user;
    }

    private function createVip1User()
    {
        $VIPuser = new VIP1();
        $this->showOnlineNum();
        $VIPuser->mylevel();

        return $VIPuser;
    }

    private function createVip2User()
    {
        $VIP2 = new Vip2();
        $this->showOnlineNum();
        $VIP2->mylevel();
        return $VIP2;

    }

    private function createVip3User()
    {
        $VIP3 = new Vip3();
        $this->showOnlineNum();
        $VIP3->mylevel();
        return $VIP3;
    }*/
}

$manager = new manager();
$manager->OpenSite();
$manager->CloseSite();


